package com.xly.webclick.presenter;

import com.xly.webclick.base.BasePresenter;
import com.xly.webclick.model.LoginData;
import com.xly.webclick.net.Request;
import com.xly.webclick.vi.CheckSMSInterface;

import static com.xly.webclick.net.RetrofitApi.VERIFICATION;

/**
 * Created by xuleyuan on 2018/8/19
 */

public class CheckSMSCodePresenter extends BasePresenter<CheckSMSInterface, LoginData> {

    @Override
    public Request<LoginData> createRequest() {
        return new Request<LoginData>().setMethod(Request.GET).setUrl(VERIFICATION);
    }

    @Override
    public void onGetResult(LoginData data) {
        if (data.getResultCode()==200){
            getBaseInterface().checkSuccess(data);
        }else {
            getBaseInterface().checkFailed(data.getResultCode());
        }
    }

    @Override
    public void onError(Throwable throwable) {
        getBaseInterface().checkFailed(500);
    }

}
